package service.impl;

import entity.Book;
import entity.BookList;
import service.IOperation;

/**
 * 修改图书信息
 */
public class ModifyBookIOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行的是“修改图书”的操作(*^▽^*)");
        System.out.println("当前所有图书信息如下");
        bookList.displayBooks();
        System.out.println("请输入需要修改图书的名称：");
        String bookName = scanner.next();
        Book newBook = null;
        if (bookList.contain(bookName)) {
            newBook = bookList.findBook(bookName);
            System.out.println("请输入新的图书单价：");
            double price = scanner.nextDouble();
            newBook.setPrice(price);
            System.out.println("修改图书价格成功(*^▽^*)");
            return;
        }
        System.out.println("修改失败！请核对图书名称。");
    }
}
